﻿using System;

namespace WordCloudHelper
{
    // Token: 0x02000003 RID: 3
    internal class IntegralImage
    {
        // Token: 0x0600000F RID: 15 RVA: 0x0000215E File Offset: 0x0000035E
        public IntegralImage(int width, int height)
        {
            this.Integral = new uint[width, height];
            this.Width = width;
            this.Height = height;
        }

        // Token: 0x06000010 RID: 16 RVA: 0x00002181 File Offset: 0x00000381
        public void Update(FastImage image)
        {
            this.Update(image, 1, 1);
        }

        // Token: 0x06000011 RID: 17 RVA: 0x0000218C File Offset: 0x0000038C
        public void Update(FastImage image, int posX, int posY)
        {
            if (posX < 1)
            {
                posX = 1;
            }
            if (posY < 1)
            {
                posY = 1;
            }
            for (int i = posY; i < image.Height; i++)
            {
                for (int j = posX; j < image.Width; j++)
                {
                    byte b = 0;
                    for (int k = 0; k < image.PixelFormatSize; k++)
                    {
                        b |= image.Data[i * image.Stride + j * image.PixelFormatSize + k];
                    }
                    this.Integral[j, i] = (uint)b + this.Integral[j - 1, i] + this.Integral[j, i - 1] - this.Integral[j - 1, i - 1];
                }
            }
        }

        // Token: 0x06000012 RID: 18 RVA: 0x00002240 File Offset: 0x00000440
        public ulong GetArea(int xPos, int yPos, int sizeX, int sizeY)
        {
            ulong num = (ulong)(this.Integral[xPos, yPos] + this.Integral[xPos + sizeX, yPos + sizeY]);
            return num - (ulong)(this.Integral[xPos + sizeX, yPos] + this.Integral[xPos, yPos + sizeY]);
        }

        // Token: 0x17000008 RID: 8
        // (get) Token: 0x06000013 RID: 19 RVA: 0x00002294 File Offset: 0x00000494
        // (set) Token: 0x06000014 RID: 20 RVA: 0x0000229C File Offset: 0x0000049C
        public int Width { get; set; }

        // Token: 0x17000009 RID: 9
        // (get) Token: 0x06000015 RID: 21 RVA: 0x000022A5 File Offset: 0x000004A5
        // (set) Token: 0x06000016 RID: 22 RVA: 0x000022AD File Offset: 0x000004AD
        public int Height { get; set; }

        // Token: 0x1700000A RID: 10
        // (get) Token: 0x06000017 RID: 23 RVA: 0x000022B6 File Offset: 0x000004B6
        // (set) Token: 0x06000018 RID: 24 RVA: 0x000022BE File Offset: 0x000004BE
        protected uint[,] Integral { get; set; }
    }
}
